package com.ht.base.system.biz.convert;

import com.ht.base.system.common.pojo.bo.AppSystemBO;
import com.ht.base.system.dao.domain.AppSystemDO;
import org.apache.commons.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * BO与DO实体类转换
 * 应用列管理对象 app_system
 * @author hdengxian
 *  @date 2023-10-07
 */
public class AppSystemBeanUtil {

    public static AppSystemDO convertToDO(AppSystemBO srcObj) {
        AppSystemDO targetObj = new AppSystemDO();
        if (srcObj == null) {
            return targetObj;
        }

        targetObj.setId(srcObj.getAppSystemId());//$column.columnComment
        targetObj.setAppId(srcObj.getAppId());//应用ID
        targetObj.setSecretKey(srcObj.getSecretKey());//应用唯一密钥
        targetObj.setAppName(srcObj.getAppName());//应用名称
        targetObj.setAppStatus(srcObj.getAppStatus());//应用状态（0-正常，1-禁止访问，2-部分接口可访问）
        targetObj.setAccessUrl(srcObj.getAccessUrl());//前端访问链接
        targetObj.setCreateBy(srcObj.getCreateBy());//创建者
        targetObj.setCreateTime(srcObj.getCreateTime());//创建时间
        targetObj.setUpdateBy(srcObj.getUpdateBy());//更新者
        targetObj.setUpdateTime(srcObj.getUpdateTime());//更新时间
        targetObj.setRemark(srcObj.getRemark());//备注
        return targetObj;
    }

    public static AppSystemBO convertToBO(AppSystemDO srcObj) {
        AppSystemBO targetObj = new AppSystemBO();
        if (srcObj == null) {
            return targetObj;
        }

        targetObj.setAppSystemId(srcObj.getId());//$column.columnComment
        targetObj.setAppId(srcObj.getAppId());//应用ID
        targetObj.setSecretKey(srcObj.getSecretKey());//应用唯一密钥
        targetObj.setAppName(srcObj.getAppName());//应用名称
        targetObj.setAppStatus(srcObj.getAppStatus());//应用状态（0-正常，1-禁止访问，2-部分接口可访问）
        targetObj.setAccessUrl(srcObj.getAccessUrl());//前端访问链接
        targetObj.setCreateBy(srcObj.getCreateBy());//创建者
        targetObj.setCreateTime(srcObj.getCreateTime());//创建时间
        targetObj.setUpdateBy(srcObj.getUpdateBy());//更新者
        targetObj.setUpdateTime(srcObj.getUpdateTime());//更新时间
        targetObj.setRemark(srcObj.getRemark());//备注
        return targetObj;
    }

    public static List<AppSystemBO> convertToBOList(List<AppSystemDO> doList) {
        List<AppSystemBO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) {
            return boList;
        }

        doList.stream().forEach(d -> boList.add(AppSystemBeanUtil.convertToBO(d)));
        return boList;
    }

    public static List<AppSystemDO> convertToDOList(List<AppSystemBO> boList) {
        List<AppSystemDO> doList = new ArrayList<>();
        if (CollectionUtils.isEmpty(boList)) {
            return doList;
        }

        boList.stream().forEach(b -> doList.add(AppSystemBeanUtil.convertToDO(b)));
        return doList;
    }

}